using System.Data;
using System.Data.SqlClient;
using Provausio.Common.Data;
using Provausio.Common.Objects;
using TrainingManagement.api.Models.BusinessObjects;

namespace TrainingManagement.api.Models.Data.CRUD.Position
{
    public class PositionSkillSetDeleteDataSource : NonQuerySource<PositionSkillSetDto>
    {
        public override bool Execute(PositionSkillSetDto request)
        {
            const string deletePositionSkillSet = "dbo.training_api_PositionSkillSetDelete";
            var parameters = new SqlParameter[2];
            parameters[0] = new SqlParameter("@PositionID", SqlDbType.Int){Value = request.PositionId};
            parameters[1] = new SqlParameter("@SkillSetID", SqlDbType.Int){Value = request.SkillSetId};

            return SqlHelper.ExecuteNonQuery(
                    ConnectionStrings.TrainingDb,
                    CommandType.StoredProcedure,
                    deletePositionSkillSet,
                    parameters) != 0;
        }
    }
}